﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HZ.Supervise.Model;

namespace HZ.Supervise.Web.Secondphase.ReportSort
{
    public partial class SortGoodsDetail : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["query"] = URLUtil.GetSuperviseQueryFromURL(Request);
                SuperviseQuery sq = (SuperviseQuery)ViewState["query"];
                if (!string.IsNullOrEmpty(sq.Mid)) //如果月份为空 参数有误
                {
                    BindList();
                }
                else
                {
                    Response.Write("<script>history.go(-1);<script>");
                }
            }
        }
        void BindList()
        {
            
            int t = 0;
            IList<HZ.Supervise.Model.Supervise> CompanyList;
            HZ.Supervise.BLL.BLL_Statistics Bll_sta = (HZ.Supervise.BLL.BLL_Statistics)HZ.Supervise.BLLFactory.IBLL_Statistics();
           
            SuperviseQuery sq = (SuperviseQuery)ViewState["query"];
            string time = sq.Mid;
            sq.Append = Function.FormatPlanTime("PlanTime",time);
            sq.Mid = "";

            sq.SortFields = "ProductName ASC";

            CompanyList = Bll_sta.GetTradeInfo(sq, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out t);
            AspNetPager1.RecordCount = t;
            sq.Mid = time;
            this.gvwDetail.DataSource = CompanyList;
            this.gvwDetail.DataBind();

        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
            SuperviseQuery sq = (SuperviseQuery)ViewState["query"];
            sq.Pack = this.txtPack.Text.Trim();
            sq.ProductName = this.txtProductName.Text.Trim();
            sq.MedicineModelName = this.txtMedicineModelName.Text.Trim();
            sq.Unit = this.txtUnit.Text.Trim();
            sq.Outlookc = this.txtOutlookc.Text.Trim();
            AspNetPager1.CurrentPageIndex = 1;
            BindList();
        }
    }
}
